Full source code website bán hàng thương mại điện tử gần giống shopee
468.788 lượt xem;
1 <table height="28" cellSpacing="0" cellPadding="0" width="100%" border="0">
2 <tr align=center>
3 <td class="title" width="100%" height="17">
4 Giá: <b> <a href="./?act=price_m&page=<? echo $_REQUEST['page']; ?>"><font color="#FFFFFF">Nhập
5 Mới</font></a><font color="#FFFFFF"> |</font></b></td>
6 </tr>
7 </table>
8 <?
9 switch ($_GET['action'])
10 {
11 case 'del' :
12 $id = $_GET['id'];
13 $news=GetPriceInfo($id);
14 if ($news)
15 {
16 @$result = mysql_query("delete from price where dv_id=".$id,$con);
17 if ($result) echo "<p align=center class='err'>Đã xóa thành công</p>";
18 else echo "<p align=center class='err'>Không thể xóa dữ liệu</p>";
19 } else {
20 echo "<p align=center class='err'>Đang có sản phẩm sử dụng đơn vị này nên bạn không thể xóa</p>";
21 }
22 break;
23 }
24 ?>
25
26 <?
27 if (isset($_POST['ButDel'])) {
28 $cnt=0;
29 foreach ($_POST['chk'] as $id)
30 {
31 $news=GetPriceInfo($id);
32 if ($news)
33 {
34 @$result = mysql_query("delete from price where dv_id=".$id,$con);
35 if ($result) $cnt++;
36 }
37 }
38 echo "<p align=center class='err'>Đã xóa ".$cnt." phần tử</p>";
39 }
40 ?>
41 <?
42 $page = $_GET["page"];
43 $p=0;
44 if ($page!='') $p=$page;
45 $where="1=1";
46 ?>
47 <form method="POST" action="<? echo $_SERVER[PHP_SELF]; ?>" name="frmList">
48 <input type=hidden name="page" value="<? echo $page; ?>">
49 <?
50 function taotrang($sql,$link,$nitem,$itemcurrent)
51 { global $con;
52 $ret="";
53 $result = mysql_query($sql, $con) or die('Error' . mysql_error());
54 $value = mysql_fetch_array($result);
55 $plus = (($value['cnt'] % $nitem)>0);
56 for ($i=0;$i<($value[0] / $nitem) + plus;$i++)
57 {
58 if ($i<>$itemcurrent) $ret .= "<a href=\"".$link.$i."\" class=\"lslink\">".($i+1)."</a> ";
59 else $ret .= ($i+1)." ";
60 }
61 return $ret;
62 }
63 $pageindex=taotrang("select count(*) from price where $where","./?act=price&page=",$MAXPAGE,$page);
64 ?>
65
66 <table cellspacing="0" cellpadding="0" width="100%">
67 <tr>
68 <td class="smallfont">Trang : <? echo $pageindex; ?></td>
69 <td height="30" align="right" class="smallfont">
70 </td>
71 </tr>
72 </table>
73
74 <table border="1" cellpadding="2" style="border-collapse: collapse" bordercolor="#C9C9C9" width="100%" id="AutoNumber1">
75 <tr>
76 <td align=center nowrap class="title"><input type="checkbox" name="chkall" onclick="chkallClick(this);"></td>
77 <td nowrap class="title"> </td>
78 <td nowrap class="title"> </td>
79 <td align="center" nowrap class="title"><b>Mã</b></td>
80 <td align="center" nowrap class="title"><b>Tên Giá</b></td>
81 <td align="center" nowrap class="title"><b>Giá</b></td>
82
83 </tr>
84
85 <?
86 $sql="select * from price where $where limit ".($p*$MAXPAGE).",".$MAXPAGE;
87 $result=mysql_query($sql,$con);
88 $i=0;
89 while(($row=mysql_fetch_array($result)))
90 {
91 $i++;
92 if ($i%2) $color="#d5d5d5"; else $color="#e5e5e5";
93 ?>
94
95 <tr>
96 <td width="20" align="center" bgcolor="<? echo $color; ?>" class="smallfont">
97 <input type="checkbox" name="chk[]" value="<? echo $row['dv_id']; ?>"></td>
98 <td width="20" bgcolor="<? echo $color; ?>" class="smallfont">
99 <a href="./?act=price_m&page=<? echo $_REQUEST['page']; ?>&id=<? echo $row['dv_id']; ?>">Sửa</a></td>
100 <td width="20" bgcolor="<? echo $color; ?>" class="smallfont">
101 <a onclick="return confirm('Bạn có chắc chắn muốn xoá ?');" href="./?act=donvi&action=del&page=<? echo $_REQUEST['page']; ?>&id=<? echo $row['dv_id']; ?>">Xóa</a></td>
102 <td width="20" bgcolor="<? echo $color; ?>" align="left" width="55" align="left" class="smallfont"><? echo $row['categories_id']; ?> </td>
103 <td bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['dv_name']; ?> </td>
104 <td bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['parent_id']; ?> </td>
105 </tr>
106 <?
107 }
108 ?>
109 </table>
110 <input type="submit" value="Xóa Chọn" name="ButDel" onclick="return confirm('Bạn có chắc chắn muốn xoá ?');" class="button" style="padding: 0">
111 <input type="hidden" name="act" value="price">
112 </form>
113 <script language="JavaScript">
114 function chkallClick(o) {
115 var form = document.frmList;
116 for (var i = 0; i < form.elements.length; i++) {
117 if (form.elements[i].type == "checkbox" && form.elements[i].name!="chkall") {
118 form.elements[i].checked = document.frmList.chkall.checked;
119 }
120 }
121 }
122 </script>
2 <tr align=center>
3 <td class="title" width="100%" height="17">
4 Giá: <b> <a href="./?act=price_m&page=<? echo $_REQUEST['page']; ?>"><font color="#FFFFFF">Nhập
5 Mới</font></a><font color="#FFFFFF"> |</font></b></td>
6 </tr>
7 </table>
8 <?
9 switch ($_GET['action'])
10 {
11 case 'del' :
12 $id = $_GET['id'];
13 $news=GetPriceInfo($id);
14 if ($news)
15 {
16 @$result = mysql_query("delete from price where dv_id=".$id,$con);
17 if ($result) echo "<p align=center class='err'>Đã xóa thành công</p>";
18 else echo "<p align=center class='err'>Không thể xóa dữ liệu</p>";
19 } else {
20 echo "<p align=center class='err'>Đang có sản phẩm sử dụng đơn vị này nên bạn không thể xóa</p>";
21 }
22 break;
23 }
24 ?>
25
26 <?
27 if (isset($_POST['ButDel'])) {
28 $cnt=0;
29 foreach ($_POST['chk'] as $id)
30 {
31 $news=GetPriceInfo($id);
32 if ($news)
33 {
34 @$result = mysql_query("delete from price where dv_id=".$id,$con);
35 if ($result) $cnt++;
36 }
37 }
38 echo "<p align=center class='err'>Đã xóa ".$cnt." phần tử</p>";
39 }
40 ?>
41 <?
42 $page = $_GET["page"];
43 $p=0;
44 if ($page!='') $p=$page;
45 $where="1=1";
46 ?>
47 <form method="POST" action="<? echo $_SERVER[PHP_SELF]; ?>" name="frmList">
48 <input type=hidden name="page" value="<? echo $page; ?>">
49 <?
50 function taotrang($sql,$link,$nitem,$itemcurrent)
51 { global $con;
52 $ret="";
53 $result = mysql_query($sql, $con) or die('Error' . mysql_error());
54 $value = mysql_fetch_array($result);
55 $plus = (($value['cnt'] % $nitem)>0);
56 for ($i=0;$i<($value[0] / $nitem) + plus;$i++)
57 {
58 if ($i<>$itemcurrent) $ret .= "<a href=\"".$link.$i."\" class=\"lslink\">".($i+1)."</a> ";
59 else $ret .= ($i+1)." ";
60 }
61 return $ret;
62 }
63 $pageindex=taotrang("select count(*) from price where $where","./?act=price&page=",$MAXPAGE,$page);
64 ?>
65
66 <table cellspacing="0" cellpadding="0" width="100%">
67 <tr>
68 <td class="smallfont">Trang : <? echo $pageindex; ?></td>
69 <td height="30" align="right" class="smallfont">
70 </td>
71 </tr>
72 </table>
73
74 <table border="1" cellpadding="2" style="border-collapse: collapse" bordercolor="#C9C9C9" width="100%" id="AutoNumber1">
75 <tr>
76 <td align=center nowrap class="title"><input type="checkbox" name="chkall" onclick="chkallClick(this);"></td>
77 <td nowrap class="title"> </td>
78 <td nowrap class="title"> </td>
79 <td align="center" nowrap class="title"><b>Mã</b></td>
80 <td align="center" nowrap class="title"><b>Tên Giá</b></td>
81 <td align="center" nowrap class="title"><b>Giá</b></td>
82
83 </tr>
84
85 <?
86 $sql="select * from price where $where limit ".($p*$MAXPAGE).",".$MAXPAGE;
87 $result=mysql_query($sql,$con);
88 $i=0;
89 while(($row=mysql_fetch_array($result)))
90 {
91 $i++;
92 if ($i%2) $color="#d5d5d5"; else $color="#e5e5e5";
93 ?>
94
95 <tr>
96 <td width="20" align="center" bgcolor="<? echo $color; ?>" class="smallfont">
97 <input type="checkbox" name="chk[]" value="<? echo $row['dv_id']; ?>"></td>
98 <td width="20" bgcolor="<? echo $color; ?>" class="smallfont">
99 <a href="./?act=price_m&page=<? echo $_REQUEST['page']; ?>&id=<? echo $row['dv_id']; ?>">Sửa</a></td>
100 <td width="20" bgcolor="<? echo $color; ?>" class="smallfont">
101 <a onclick="return confirm('Bạn có chắc chắn muốn xoá ?');" href="./?act=donvi&action=del&page=<? echo $_REQUEST['page']; ?>&id=<? echo $row['dv_id']; ?>">Xóa</a></td>
102 <td width="20" bgcolor="<? echo $color; ?>" align="left" width="55" align="left" class="smallfont"><? echo $row['categories_id']; ?> </td>
103 <td bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['dv_name']; ?> </td>
104 <td bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['parent_id']; ?> </td>
105 </tr>
106 <?
107 }
108 ?>
109 </table>
110 <input type="submit" value="Xóa Chọn" name="ButDel" onclick="return confirm('Bạn có chắc chắn muốn xoá ?');" class="button" style="padding: 0">
111 <input type="hidden" name="act" value="price">
112 </form>
113 <script language="JavaScript">
114 function chkallClick(o) {
115 var form = document.frmList;
116 for (var i = 0; i < form.elements.length; i++) {
117 if (form.elements[i].type == "checkbox" && form.elements[i].name!="chkall") {
118 form.elements[i].checked = document.frmList.chkall.checked;
119 }
120 }
121 }
122 </script>